<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<html>
<head>
    <title>添加文章信息</title>
    <%@ include file="../../common/base.jsp" %>

    <script type="text/javascript">

        function addSubmit() {
            if (!validateContentNotNull('title',1,60,'文章标题',true)) {
                return false;
            }
            if (!validateContentNotNull('articleUrl',1,60,'文章链接地址',true)) {
                return false;
            }

            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/article/saveArticle",
                dataType: "json",
                data: getParams(),
                success: function (data) {
                    if (data.errorCode == 0) {
                        prompt.alert("添加文章成功！");

                        setTimeout(function () {
                            window.location.href = "${pageContext.request.contextPath}/article/showArticle";
                        }, 2000);
                    } else {
                        prompt.alert(data.msg);
                    }
                }
            });
        }

        //获取form表单所有参数
        function getParams() {
            var json = {};
            $(".content input").each(function (i, e) {
                json[$(e).attr("id")] = $(e).attr("value");
            });
            var content = $("#content").val();
            json["content"] = content;
            return json;
        }

    </script>

</head>

<body id="body">
<!--head-->
<div id="head">
    <jsp:include page="../../common/head.jsp"></jsp:include>
</div>
<!--head end-->
<!--container-->
<div id="container">
    <div id="pageId" style="display: none;">05-07-02</div>
    <!--sidebar-->
    <%@ include file="../../common/menu.jsp" %>
    <!--sidebar-->
    <!--main-->
    <div class="main" id="mainDiv">
        <div class="channel_manage">
            <div class="location" style="background-position:22px -29px;">
                平台管理<span>&gt;</span>APP首页配置<span>&gt;</span>文章管理<span>&gt;</span>添加文章
            </div>
            <form method="post" enctype="multipart/form-data">
                <!--content-->
                <div class="content">
                    <div class="inputInfoList3">
                        <ul class="recharge_list" style="width:600;">
                            <li>
                                <label>文章标题</label>
                                <input type="text" id="title" name="title"
                                       onFocus="this.style.border = '1px solid #2A7CCF'"
                                       onblur="validateContentNotNull('title',1,60,'文章标题');this.style.border = '1px solid #D5D5D5'"/>
                                <span style="position:absolute;left:76%;top:9px;color:red;" class="red">*</span>
                                <i style="display: none;background-position: left center;" id="titles" class="s_tips"></i>
                                <i style="display: none;background-position: left center;padding-left:28%;" id="titleZhu" class="zhu_shi_2"></i>
                            </li>
                            <li>
                                <label>文章链接地址</label>
                                <input type="text" id="articleUrl" name="articleUrl"
                                       onFocus="this.style.border = '1px solid #2A7CCF'"
                                       onblur="validateContentNotNull('articleUrl',1,60,'文章链接地址');this.style.border = '1px solid #D5D5D5'"/>
                                <span style="position:absolute;left:76%;top:9px;color:red;" class="red">*</span>
                                <i style="display: none;background-position: left center;" id="articleUrls" class="s_tips"></i>
                                <i style="display: none;background-position: left center;padding-left:28%;" id="articleUrlZhu" class="zhu_shi_2"></i>
                            </li>
                            <li>
                                <label>文章内容</label>
                                <textarea id="content" name="content" rows="8" style="width: 310px;"></textarea>
                            </li>
                        </ul>
                        <div class="button_wrap">
                            <a href="javascript:void(0);" onClick="addSubmit();" class="bg_green">完成</a>
                            <input type="reset" value="重置">
                        </div>
                    </div>
                </div>
                <!--content-->
            </form>
            <!--foot-->
            <%@ include file="../../common/foot.jsp" %>
            <!--foot-->
        </div>
    </div>
    <!--main-->
</div>
<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>

</body>
</html>
